﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//引用命名空间
using System.Data.SqlClient;

namespace ch05
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //创建连接对象
            SqlConnection conn = new SqlConnection();
            //设置连接字符串
            conn.ConnectionString = "server=SIT-20220823GSX\\SQLSEVER;database=stuSys;uid=sa;pwd=";
            //打开连接
            conn.Open();

            MessageBox.Show("连接成功！");

            //关闭连接
            conn.Close();
        }
    }
}
